#!/usr/bin/python
import os
import sys
import argparse
import flowtool
import http_tls

parser = argparse.ArgumentParser("This program includes all kinds of QA testing scripts.")

parser.add_argument("--flowtool"
                    , help = "Run flowtool against a single pcap file."
                    , metavar = "path_pcap_file")

parser.add_argument("--flowtool_folder"
                    , help = "Run flowtool against all pcap files in this directory and sub-directories."
                    , metavar = "path_pcap_folder")

parser.add_argument("--miss_http_tls"
                    , help = "Look through this file to find fail classified HTTP & TLS hosts & referers."
                    , metavar = ("path_flowtool_output", "path_output")
                    , nargs = 2)

parser.add_argument("--miss_http_tls_folder"
                    , help = "Look through folders for '.pkt.log' file to find fail classified HTTP & TLS hosts & referers. "
                    , metavar = ("path_flowtool_output", "path_output")
                    , nargs = 2)

args = parser.parse_args()

def main():
    if args.flowtool:
        ft = flowtool.Flowtool()
        ft.run_flowtool(args.flowtool)
        
    elif args.flowtool_folder:
        ft = flowtool.Flowtool()
        ft.run_flowtool_folder(args.flowtool_folder)
    
    elif args.miss_http_tls:
        ft = flowtool.Flowtool()
        ft.run_flowtool(args.miss_http_tls[0])
        ht = http_tls.HttpTls()
        ht.missed_http_tls(args.miss_http_tls[0], args.miss_http_tls[1])
        
    elif args.miss_http_tls_folder:
        ft = flowtool.Flowtool()
        ft.run_flowtool_folder(args.miss_http_tls_folder[0])
        ht = http_tls.HttpTls()
        ht.missed_http_tls_folder(args.miss_http_tls_folder[0], args.miss_http_tls_folder[1])

if __name__ == "__main__":
    sys.exit(main())